import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'font-awesome/css/font-awesome.css'
import axios from 'axios'
import VueAxios from 'vue-axios'
import api from './assets/js/api'
import websocket from './assets/js/websocket'

Vue.config.productionTip = false
Vue.use(VueAxios,axios,global)
Vue.prototype.$api = api
Vue.prototype.$websocket = websocket
String.prototype.timer = function(){return this.split('T')[0] + ' ' + this.split('T')[1].split(':').slice(0,2).join(':')}
Vue.directive('drag', {
  // 自定义拖拽指令
  bind: function(el){
    el.style.position = 'fixed'
    el.onmousedown = (e) => {
      let X = e.clientX - el.offsetLeft
      let Y = e.clientY - el.offsetTop
      document.onmousemove = (e) => {
        let left = e.clientX - X
        let top = e.clientY - Y
        el.style.left = left + 'px'
        el.style.top = top + 'px'
      }
      document.onmouseup = () => {
        document.onmousemove = null
        document.onmouseup = null
      };
    }
  }
},)
Vue.directive('layz',{
  bind: function(el){
    el.src = el.src + '?t=' + Math.random()
  }
})


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
